package com.res.share.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.res.share.model.ResUserScore;
import com.res.share.mapper.ResUserScoreMapper;
import com.res.share.service.IResUserScoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 积分明细 服务实现类
 * </p>
 *
 * @author astupidcoder
 * @since 2021-09-13
 */
@Service
public class ResUserScoreServiceImpl extends ServiceImpl<ResUserScoreMapper, ResUserScore> implements IResUserScoreService {

    @Override
    public IPage<ResUserScore> findMyjifenList(Page<ResUserScore> page, Integer userId) {
        return baseMapper.findMyjifenList(page,userId);
    }

    @Override
    public Integer findMyScoreTotal(Integer userId) {
        return baseMapper.findMyScoreTotal(userId);
    }

    @Override
    public Integer findUserSignExits(Integer userId) {
        return baseMapper.findUserSignExits(userId);
    }

    @Override
    public void saveUserScore(Integer userId) {
        ResUserScore resUserScore=new ResUserScore();
        resUserScore.setUserId(userId);
        resUserScore.setResFrom("签到");
        resUserScore.setType(0);
        resUserScore.setStatus(0);
        resUserScore.setScore(1);
        resUserScore.setCreateUserId(userId);
        baseMapper.insert(resUserScore);
    }

    @Override
    public int saveResScoreData(ResUserScore resUserScore) {
        int insert = baseMapper.insert(resUserScore);
        return insert;
    }
}
